package Zhang7;

import java.util.concurrent.atomic.AtomicReference;
class Book {
    private String title;
    //图书名称
    private double price;

    //图书价格
    public Book(String title, double price) {
        this.title = title;
//属性赋值
        this.price = price;
    }

    @Override
    public String toString() {
        return "【图书】名称=" + this.title + "、价格=" + this.price;
    }
}
public class AtomicReferenceZhang7{
    public static void main(String[] args) throws Exception{
        Book book=new Book("Java就业编程实战",69.8);
        //实例化Book类对象
        AtomicReference<Book> ref=new AtomicReference<Book>(book);//原子引用
        ref.compareAndSet(book,new Book("Spring就业编程实战",67.8));//CAS操作
        System.out.println(ref);
    }
}


